<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*" contentType="text/html; charset=utf-8" %>

<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

String login_id = null;
String user_id = null;

if(userSession!= null){
	login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
}

String lrg_code = CommonUtil.nvl(request.getParameter("lrg_code"));
String sml_code = CommonUtil.nvl(request.getParameter("sml_code"));


%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<script language='javascript' src="/js/ajaxutil.js"></script>
<script>


function go_input(){
	var frm = document.mainform;	
	
	
	if(frm.lrg_code.value==''){
		alert('대분류를 선택 해주세요');
		frm.lrg_code.focus();
		return;
	}
	if(frm.sml_code.value==''){
		alert('중분류를 선택 해주세요');
		frm.sml_code.focus();
		return;
	}
	if(frm.level_code.value==''){
		alert('난이도를 선택 해주세요');
		frm.level_code.focus();
		return;
	}
	
	if(frm.attachFile_1.value==''){
		alert('지문음성을 등록 해주세요');
		frm.attachFile_1.focus();
		return;
	}
	/*
	if(frm.attachFile_3.value==''){
		alert('모범답안을 등록 해주세요');
		frm.attachFile_3.focus();
		return;
	}
	*/
	
	//frm.cmd.value='opicexam_insert';
	frm.action = '/speaking.pb?cmd=opicexam_insert';
	frm.target= 'hidden_frm';              
	frm.submit();	
}

function go_opicexam(){
	
	var frm = document.moveform;	
	frm.cmd.value='opicexam_main';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();
	
}

function init_opicexam(){
	form = document.mainform;
	setSPSelect(form.lrg_code,'<%=lrg_code%>', '대분류선택', 'lrg');
	<%if(!lrg_code.equals("")){%>
	setSPSelect(form.sml_code,'<%=sml_code %>', '중분류선택', '<%=lrg_code%>|sml');
	<%}%>
	setSPSelect(form.level_code,'', '난이도선택', 'level');
    
}

function go_exam_preview(){
	var popleft = (screen.width - 300)/2;
	var poptop = (screen.height - 450)/2;
	var url="/jsp/sp_sp0106_exam_preview.jsp";
	var open_preview = window.open(url,'preview','width=300,height=450,resizable=yes,scrollbars=yes,top='+poptop+',left='+popleft);
	open_preview.focus();
}

function go_answer_preview(){
	var popleft = (screen.width - 485)/2;
	var poptop = (screen.height - 415)/2;
	var url="/jsp/sp_sp0106_answer_preview.jsp";
	var open_preview2 = window.open(url,'preview2','width=485,height=415,resizable=yes,scrollbars=yes,top='+poptop+',left='+popleft);
	open_preview2.focus();
}

function go_exam_preview_frm(){
	
	var url="/jsp/sp_sp0106_exam_preview_frm.jsp";
	
	exam_preview.location.href = url;
}

function go_answer_preview_frm(){
	
	var url="/jsp/sp_sp0106_answer_preview_frm.jsp";
	answer_preview.location.href = url;
}

function go_selectLrg(v){
	if(v != ''){
		setSPSelect(form.sml_code,'', '중분류선택', v+'|sml');
	}else{
		setSPSelect(form.sml_code,'', '중분류선택', '0|sml');
	}
}
window.onload = init_opicexam;
</script>

<jsp:include page="/jsp/common/top.jsp"></jsp:include>
<jsp:include page="/jsp/common/submenu.jsp"><jsp:param name="submenu_id" value="level_main" /><jsp:param name="submenu_idx" value="5" /></jsp:include>

<form name="mainform"  method="post" action = "/speaking.pb" enctype= "multipart/form-data">
	<div id="bodyContainer">
        <div id="contents">
          <jsp:include page="/jsp/common/submenu_list.jsp"><jsp:param name="submenu_id" value="opicexam_main" /><jsp:param name="submenu_idx" value="2" /></jsp:include>
          
          
          <div class="boxContainer">
            <dl title="OPIC 문제 등록">
              <dt>OPIc 문제 등록</dt>
            </dl>
            <table class="setupTb">
            
              <tr>
                <th>대분류</th>
                <td><select name="lrg_code" id="lrg_code" onchange="go_selectLrg(this.value)" style="width:400px">
                  <option value=''>대분류</option>                 
                </select></td>
              </tr>
              <tr>
                <th>중분류</th>
                <td><select name="sml_code" id="sml_code" style="width:400px">
                  <option value=''>중분류</option>                 
                </select></td>
              </tr>
              <tr>
                <th>난이도</th>
                <td><select name="level_code" id="level_code">
                  <option value=''>난이도</option>                 
                </select></td>
              </tr>
              <tr>
                <th>지문음성 등록</th>
                <td><input type="file" name="attachFile_1" id="attachFile_1" style="width:200px"/>
                </td>
              </tr>
              <!--  
              <tr>
                <th>샘플답변 등록</th>
                <td><input type="file" name="attachFile_2" id="attachFile_2" style="width:200px"/>
                  </td>
              </tr>
              -->
              <tr>
                
                
                <th>지문내용 등록</th>
                <td><textarea name="explane_cont" rows="5" id="cont" style="width:450px" onkeydown="go_exam_preview_frm()"></textarea>
                <br>
                <!-- 
                <a href="#" onclick="go_exam_preview()"><input type="button" value="미리보기" style="width:100px; height:20px"></a>
                 -->
                 <b>미리보기</b>
                <br>
                <iframe name='exam_preview'  width='300' height='200' SCROLLING='AUTO' frameborder='0'></iframe>
                
                </td>
              </tr>
              <tr>
                <th>모범답안음성 등록</th>
                <td><input type="file" name="attachFile_3" id="attachFile_3" style="width:200px"/>
                  
                  </td>
              </tr>
              <tr>
                
                
                <th>모범답안내용 등록</th>
                <td><textarea name="answer_cont" rows="5" id="cont" style="width:450px" onkeydown="go_answer_preview_frm()"></textarea>
                <br>
                <!-- 
                <a href="#" onclick="go_answer_preview()"><input type="button" value="미리보기" style="width:100px; height:20px"></a>
                 -->
                 <b>미리보기</b>
                <br>
                <iframe name='answer_preview'  width='460' height='200' SCROLLING='AUTO' frameborder='0'></iframe>
                </td>
              </tr>
              <tr>
                <th>상태</th>
                <td><input type="radio" name="use_yn" id="use_yn" value="Y" checked/><span class="boldText">노출</span><input type="radio" name="use_yn" id="use_yn" value="N" /><span class="boldText">비노출</span></td>
              </tr>
                                      
            </table>
            <p><a href="#" onclick="go_input()"><img src="img/btn_regist.gif" alt="등록" width="49" height="20" /></a> <a href="#" onclick="go_opicexam()"><img src="img/btn_list.gif" alt="목록" width="49" height="20" /></a> </p>
            
          </div>
          
        </div>
      </div>


<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">

</form>

<form name="moveform"  method="post" action = "/speaking.pb" >
<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="lrg_code" value="<%=lrg_code %>">
<input type="hidden" name="sml_code" value="<%=sml_code %>">
</form>
<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
